package com.lan.iot;


import android.content.Context;
import android.content.Intent;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Eve on 2022/10/19.
 */
public class RecyAdaptercount extends RecyclerView.Adapter {
    private List<String> nData = new ArrayList<>();
    private Context context;
    private List<Integer> count = new ArrayList<>();

    public RecyAdaptercount(Context context,List<Integer> c) {
        this.context = context;
this.count=c;
        //item中的数据
//        mData.add("客户联系");
//        mData.add("客户群");
//        mData.add("微信客服");
//        mData.add("离职继承");
//        mData.add("群发助手");
//        mData.add("对外收款");

        nData.add("客厅");
        nData.add("主卧");
        nData.add("次卧");

//        imgData.add(R.drawable.door);
//        imgData.add(R.drawable.light);
//        imgData.add(R.drawable.aircdn);
//        imgData.add(R.drawable.window);
//        imgData.add(R.drawable.music);



    }

    @NonNull
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view;
        int layoutId;
        //加载item的布局文件
        layoutId = R.layout.item_c;
        view = LayoutInflater.from(parent.getContext()).inflate(layoutId, parent, false);
        return new VH(view);
    }

    @Override
    public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, final int position) {
        final VH vh = (VH) holder;
//        vh.mText.setText(mData.get(position) + "");
        vh.nText.setText(nData.get(position));
        vh.nText.setTextColor(0xff000000);
        vh.mText.setText(count.get(position).toString());
        vh.mText.setTextColor(0xff000000);
//        vh.img.setImageResource(imgData.get(position));
        //设置item的点击事件
        //这里只设置了第一个item的，有需要的自己添加；
    }

    @Override
    public int getItemCount() {
        return nData.size();
    }

    //初始化item布局文件的各个控件
    class VH extends RecyclerView.ViewHolder {
        TextView mText, nText;
        ImageView img;

        public VH(@NonNull View itemView) {
            super(itemView);
            mText=itemView.findViewById(R.id.text);
            nText = itemView.findViewById(R.id.text1);
//            nText.setText("111");
        }
    }


}
